package com.fair.concurrency.test2;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadTest {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        // for (int i = 1; i <= 30; i++) {
        //     int finalI = i;
        //     executorService.execute(() -> {
        //         if (finalI == 15) {
        //             throw new RuntimeException("抛出异常: " + Thread.currentThread().getName());
        //         }
        //         System.out.println("i = " + finalI);
        //     });
        // }

        executorService.execute(() -> {
            for (int i = 1; i <= 300000; i++) {
                // if (i == 15) {
                //     throw new RuntimeException("抛出异常: " + Thread.currentThread().getName());
                // }
                System.out.println(Thread.currentThread().getName() + "-->" + i);
            }
        });
        executorService.shutdown();
    }
}
